package com.jack.blog.utils;

import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**
 * DateUtil
 */
public final class DateUtil {

    /**
     * acquire timestamp
     * @return
     */
    public static Timestamp getTimestamp(){
        return new Timestamp(System.currentTimeMillis());
    }

    /**
     * acquire date string by format
     */
    public static String getStringByTimestamp(Timestamp time,String format){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
        return simpleDateFormat.format(new Date(time.getTime()));
    }
    public static String getStringByTimestamp(Timestamp time){
        return getStringByTimestamp(time,"yyyy-MM-dd");
    }
}
